package com.rc.adapter;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.rc.activity.R;
import com.rc.activity.dao.tbl_Trip;

public class TripItemAdapter extends BaseAdapter {

	private Context mContext;
	private ArrayList<tbl_Trip> items;

	public TripItemAdapter(Context c, ArrayList<tbl_Trip> items) {
		mContext = c;
		this.items = items;
	}

	public int getCount() {
		return items.size();
	}

	public Object getItem(int position) {
		return items.get(position);
	}

	public long getItemId(int position) {
		return 0;
	}

	private View v;

	// create a new view for each item referenced by the Adapter
	@SuppressLint("ResourceAsColor")
	public View getView(final int position, View convertView, ViewGroup parent) {
		v = convertView;
		if (convertView == null) { // if it's not recycled, initialize some
									// attributes
			LayoutInflater vi = (LayoutInflater) mContext
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.categorize_list_item, null);
		}
		TextView txtText = (TextView) v.findViewById(R.id.txtText);
		txtText.setText(items.get(position).getName());
		return v;
	}

	public void NotiDB(ArrayList<tbl_Trip> items) {
		this.items = items;
		notifyDataSetChanged();
	}
}